//=======================================================
// 作者：KingSley
// 描述：在主摄像机下，通过DOTween实现对透明度，动画的播放情况等控制（飘字效果）
//=======================================================
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using DG.Tweening;
using System.Collections.Generic;
using System;
using System.IO;

namespace Babybus.Uno
{
    public class MainCameraDotweenUseOnAll : MonoBehaviour
    {
        /// <summary>
        /// 飘字效果
        /// </summary>
        /// 
        static Sequence mySequence;                       //创建空序列  

        public static void FlyTo(Graphic graphic)
        {
            RectTransform rt = graphic.rectTransform;
            Color c = graphic.color;
            c.a = 0;
            graphic.color = c;
            mySequence = DOTween.Sequence();//先将字体透明  
            //Sequence mySequence = DOTween.Sequence();                            //创建空序列  
            Tweener move1 = rt.DOMoveY(rt.position.y + 20, 0.5f);                //创建向上移动的第一个动画  
            Tweener move2 = rt.DOMoveY(rt.position.y + 40, 0.5f);                //创建向上移动的第二个动画  
            Tweener alpha1 = graphic.DOColor(new Color(c.r, c.g, c.b, 1), 0.5f); //创建Alpha由0到1渐变的动画  
            Tweener alpha2 = graphic.DOColor(new Color(c.r, c.g, c.b, 0), 0.5f); //创建Alpha由1到0渐变的动画  
            mySequence.Append(move1);                  //先添加向上移动的动画  
            mySequence.Join(alpha1);                   //同时执行Alpha由0到1渐变的动画  
            mySequence.AppendInterval(1);              //延迟1秒钟  
            mySequence.Append(move2);                  //添加向上移动的动画  
            mySequence.Join(alpha2);                   //同时执行Alpha由1到0渐变的动画 
        }

        public void ModifyMesh(Mesh mesh)
        {
            
        }

        private void Start()
        {
            DOTween.useSafeMode = false;
            Text text = GameObject.Find("Text2").GetComponent<Text>();
            FlyTo(text);
            //ModifyMesh(GameObject.Find("Text2").GetComponent<Mesh>());
        }

    }
}
